package cn.tedu.sp04.order.service;

import cn.tedu.sp01.pojo.User;
import cn.tedu.web.util.JsonResult;
import org.springframework.stereotype.Component;

import java.util.ArrayList;

@Component
public class UserClientFB implements UserClient {
    @Override
    public JsonResult<User> getUser(Integer userId) {
        //模拟缓存
        if(Math.random()<0.5){
            ArrayList<User> users = new ArrayList<>();
            users.add(new User(userId, "用户", "缓存密码"));
            return JsonResult.ok().data(users);
        }
        return JsonResult.err("无法获取用户信息");
    }

    @Override
    public JsonResult addScore(Integer userId, Integer score) {

        return JsonResult.err("无法增加用户积分");
    }
}
